package com.neusoft;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class CopyFile1 {

    public static void main(String[] args) throws Exception {
        //创建流对象
       long startTime = System.currentTimeMillis();
        FileInputStream fis = new FileInputStream("d:\\kjds.sql");
        FileOutputStream fos = new FileOutputStream("e:\\hhh.sql");

        //循环读取数据并且把数据写入到目标文件中
        int len = 0;
        byte[] bytes = new byte[1024];
        while((len=fis.read(bytes))!=-1){
            fos.write(bytes,0,len);
        }

        //关闭流对象：先关写入流  后关输入流   注意：关闭写入流对象  自动冲刷缓冲区
        fos.close();
        fis.close();

       long endTime = System.currentTimeMillis();
        System.out.println("复制文件耗时"+(endTime-startTime)+"毫秒");
    }
}
